package com.software.levelupandroid.notion.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.software.levelupandroid.R;
import com.software.levelupandroid.entity.Task;

import java.util.ArrayList;
import java.util.List;

public class ItemAdapter extends BaseAdapter {
    private Context context;
    private List<String> list = new ArrayList<>();
    private boolean isToday;

    public ItemAdapter() {
    }

    public ItemAdapter(Context context, List<String> list,boolean isToday) {
        this.context = context;
        this.list = list;
        this.isToday = isToday;
    }
    @Override
    public int getCount() {
        if(isToday) {
            return list.size();
        }else {
            return 1;
        }

    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.tady_item, null);
        TextView textView = (TextView) convertView.findViewById(R.id.item);
        textView.setText(list.get(position));
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //todo 跳转详情
                //Toast.makeText(context, "Clicked", Toast.LENGTH_SHORT).show();
            }
        });
        return convertView;
    }
}
